Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Core java - Interview Questions and Answers for 'Proofpoint' - 3 question(s) found - Order By Newest | ||||
Very frequently asked. Favorite question in Walk in Drive of many Indian service companies. Frequently asked in HCL Technologies, TCS and Accenture. | ||||
| ||||
Ans. final - constant variable, objects cannot be de-referenced, restricting method overriding, restricting class sub classing. finally - handles exception. The finally block is optional and provides a mechanism to clean up regardless of what happens within the try block. Use the finally block to close files or to release other system resources like database connections, statements etc. finalize() - method helps in garbage collection. A method that is invoked before an object is discarded by the garbage collector, allowing it to clean up its state. | ||||
Sample Code for final Sample Code for finally Sample Code for finalize | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   oops   final   finally   finalize   final vs finally vs finalize Asked in 61 Companies basic   frequent | ||||
Try 4 Question(s) Test | ||||
Related Questions | ||||
Difference between final and effectively final ? Why is effectively final even required ? | ||||
Which of the following combination of keywords is illegal in Java ? a. static and transient b. transient and final c. static and synchronized d. abstract and final | ||||
What is a final method ? | ||||
Which keyword is used to provide explicit access of a code block to single thread ? a. Transient b. Final c. Explicit d. Synchronized | ||||
Enums cannot be declared .. | ||||
What is a Final Variable ? | ||||
Should we override finalize method ? | ||||
Will the static block be executed in the following code ? Why ? | ||||
Can we override compareTo method for Enumerations ? | ||||
Frequently asked in all types of companies especially Indian Services companies. Frequently asked in CTS (Based on 2 feedback) | ||||
| ||||
Ans. Hashcode is used for bucketing in Hash implementations like HashMap, HashTable, HashSet etc. The value received from hashcode() is used as bucket number for storing elements. This bucket number is the address of the element inside the set/map. when you do contains() then it will take the hashcode of the element, then look for the bucket where hashcode points to and if more than 1 element is found in the same bucket (multiple objects can have the same hashcode) then it uses the equals() method to evaluate if object are equal, and then decide if contain() is true or false, or decide if element could be added in the set or not. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   collections   hashcode   advanced  hashtable Asked in 33 Companies intermediate   frequent | ||||
Try 1 Question(s) Test | ||||
Related Questions | ||||
Which String class does not override the equals() and hashCode() methods, inheriting them directly from class Object? | ||||
Write a class and override the equals and hashcode method ? | ||||
How many threads can access a concurrent hashmap when the hashcode is overridden and always returns a zero. | ||||
| ||||
Ans. Abstract Classes provide default implementations of methods that are inherited by the classes that extend them, which was not the case for Interfaces. This changed in Java 8, where default implementations are provided for methods. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  abstract classes  interfaces  default method Asked in 1 Companies expert | ||||
Related Questions | ||||
Why can't we have diamond problem with interfaces ? | ||||
Does java allow implementation of multiple interfaces having Default methods with Same name and Signature ? | ||||
What are Default Methods ? | ||||
What was the driving force to introduce default methods in Interfaces wef from Java 8 ? | ||||
Can we have a private default method ? | ||||
If there is a conflict between Base Class Method definition and Interface Default method definition, Which definition is Picked ? | ||||
Can we have a default method without a Body ? | ||||
Can we have a default method definition in the interface without specifying the keyword "default" ? | ||||
Can a class implement two Interfaces having default method with same name and signature ? | ||||
What If we make the method as abstract in another Interface ? | ||||